<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<link rel="stylesheet" href="<?php echo base_url()?>skins/default/jquery.cluetip.css" type="text/css" />
<script src="<?php echo base_url()?>js/jquery.cluetip.js" type="text/javascript"></script>
<div class="middle myclear">
	<div class="pad10">
		
		<h3><?php echo $lang['banner_campaign_log']?></h3>
		
		<table class="martop10 marbottom10">
			<tr>
				<td class="pad5 ver-middle">
					<b><?php echo $lang['action']?>: </b>
					<select id="slcType" class="ver-middle">
						<option value="-1">- <?php echo $lang['select_all']?> -</option>
						<?php foreach ($lang['inform_type'] as $item	=>	$value){?>
						<option value="<?php echo $item?>" <?php echo ($el_type == $item) ? 'selected="selected"' : '';?> ><?php echo $value?></option>
						<?php }?>
					</select>
				</td>
				<td class="pad5 ver-middle">
					<b>User:</b>
					<input type="text" name="slcUser" id="slcUser" size="20" value="<?php echo $el_usr;?>" />
				</td>
				<td class="pad5 ver-middle">
					<b>ID:</b>
					<input type="text" name="slcID" id="slcID" size="20" value="<?php echo ($el_id == 0 ? '' : $el_id);?>" />
				</td>
				<td class="pad5 ver-middle">
					<b>Date:</b>
					<input type="text" size="15" name="slDate" id="slDate" value="<?php echo $el_date?>" />
				</td>
				<td class="pad5 ver-middle">
					<input type="button" value=" Go " onclick="logFilterChange()" />
				</td>
			</tr>
		</table>
		
		<table class="tbl-list" border="1" width="100%">
			<tr>
				<td class="pad5 td-label" width="10%" >
					<b><?php echo $lang['action']?></b>
				</td>
				
				<td class="pad5 td-label" width="15%" >
					<b><?php echo $lang['banner']?></b>
				</td>
				
				<td class="pad5 td-label" width="15%" >
					<b><?php echo $lang['campaign']?></b>
				</td>
				
				<td class="pad5 td-label" width="10%" >
					<b><?php echo $lang['before']?></b>
				</td>
				<td class="pad5 td-label" width="10%" >
					<b><?php echo $lang['after']?></b>
				</td>
				
				<td class="pad5 td-label" width="10%" >
					<b><?php echo $lang['id']?></b>
				</td>
				
				<td class="pad5 text-center td-label" >
					<b><?php echo $lang['time']?></b>
				</td>
				<td class="pad5 text-center td-label" >
					<b><?php echo $lang['user']?></b>
				</td>
			</tr>
			<?php $i = 1; foreach ($email_log as $row){?>
			<tr class="row">
				<td>
					<?php echo $lang['inform_type'][$row['type']]?>
				</td>
				<td>
					<?php if(!in_array($row['type'], array(20,21))) echo $row['bannername']?>
				</td>
				<td>
					<?php if(!in_array($row['type'], array(20,21))) echo $row['campaignname']?>
				</td>
				<td>
					<a class="view-cluetip" href="javascript:;" title="<?php echo $lang['before'].'|'.strip_tags($row['before']);?>">
						View
					</a>
				</td>
				<td>
					<a class="view-cluetip" href="javascript:;" title="<?php echo $lang['after'].'|'.strip_tags($row['after'])?>">
						View
					</a>
				</td>
				<td>
					<?php echo $row['id']?>
				</td>
				<td>
					<?php echo $row['createtime']?>
				</td>
				<td>
					<?php echo $row['username']?>
				</td>
			</tr>
			<?php $i++; }?>
		</table>
		<div class="brv-paging-left padtop10">
			<table class="tbl-list brv-paging" border="1">
				<tr>
					<td class="brv-paging-name">
						<?php echo $lang['page'].' '. $page.' ['.$total_page.']'?>
					</td>
					
					<td class="brv-paging-pre-next">
						<img class="brv-img-pre" alt="previous" src="/images/imgpre.gif" onclick="goPage(<?php echo $page > 1 ? $page - 1 : $page;?>)" />
						<img class="brv-img-next" alt="next" src="/images/imgnext.gif" onclick="goPage(<?php echo $page + 1;?>)" />
					</td>
				</tr>
			</table>
		</div>
	</div>
</div>
<script type="text/javascript">
$('a.view-cluetip').cluetip({sticky: true, closePosition: 'title', splitTitle: '|'});
$('#slDate').DatePicker({
	format:'Y-m-d',
	date: '<?php if($el_date!='') echo $el_date; else echo date('Y-m-d');?>',
	starts: 1,
	//onBeforeShow: function(){
		//$('#inputDate').DatePickerSetDate($('#inputDate').val(), true);
	//},
	onChange: function(formated, dates){
		$('#slDate').val(formated);
		$('#slDate').DatePickerHide();
	}
});

$(function(){
	$('.tbl-list .row').mouseover(function(){
		$(this).css('background','#ffc');
	});
	$('.tbl-list .row').mouseout(function(){
		$(this).css('background','none');
	});
});

function logFilterChange()
{
	var _query = "?";
	_query += "el_type=" + $('#slcType').val();
	_query += "&el_usr=" + $('#slcUser').val();
	_query += "&el_id=" + $('#slcID').val();
	_query += "&el_date=" + $('#slDate').val();
	
	window.location.href="<?php echo site_url('logs/show/')?>" + _query;
}
function goPage(strVal)
{
	var _query = "?";
	_query += "el_type=" + $('#slcType').val();
	_query += "&el_usr=" + $('#slcUser').val();
	_query += "&el_id=" + $('#slcID').val();
	_query += "&el_date=" + $('#slDate').val();
	_query += "&page=" + strVal;
	
	window.location.href="<?php echo site_url('logs/show/')?>" + _query;
}
</script>